<template>
  <div class="main">
    <form-search :list="searchList" :info="form" column="4" @confirm="searchConfirm"></form-search>

    <div class="wrap">
      <el-table :data="tableData" height="560" style="width: 100%;" class="table">
        <el-table-column label="红人头像" width="80">
          <template #default="scope">
            <img :src="scope.row.avatar" class="row-avatar">
          </template>
        </el-table-column>
        <el-table-column label="红人姓名" width="200">
          <template #default="scope">
            <p class="font-14 pointer" @click="toPath(`/kocNewDetail?id=${scope.row.id}`)">{{ scope.row.value }}</p>
          </template>
        </el-table-column>
        <el-table-column prop="value" label="红人国家" width="100" />
        <el-table-column prop="value" label="红人分类" width="100" />
        <el-table-column prop="value" label="是否接单" width="150" />
        <el-table-column prop="value" label="合作状态" width="150" />
        <el-table-column prop="value" label="合作阶段" width="150" />
        <el-table-column prop="value" label="对应短链" width="150" />
        <el-table-column prop="value" label="视频链接" width="150" />
        <el-table-column label="合作金额" width="150">
          <template #default="scope">
            <p class="font-14">{{ numConvert(scope.row.count, 2) }}</p>
          </template>
        </el-table-column>
        <el-table-column label="播放量" width="150">
          <template #default="scope">
            <p class="font-14">{{ numConvert(scope.row.count, 2) }}</p>
          </template>
        </el-table-column>
        <el-table-column label="点击量" width="150">
          <template #default="scope">
            <p class="font-14">{{ numConvert(scope.row.count, 2) }}</p>
          </template>
        </el-table-column>
        <el-table-column label="操作" width="176" fixed="right">
          <template #default="scope">
            <div class="row-btns flex flex-align-items-center">
              <p class="row-btn font-14 pointer">联系</p>
              <span class="line"></span>
              <p class="row-btn font-14 pointer" @click="toPath(`/blogContactDetail?id=${scope.row.id}`)">详情</p>
            </div>
          </template>
        </el-table-column>
      </el-table>
      <div class="pagination flex flex-align-items-center">
        <el-pagination :page-sizes="[10, 20, 50, 100]" layout="prev, pager, next, total" :total="form.total" />
      </div>
    </div>
  </div>
</template>

<script setup>
import FormSearch from '../../components/formSearch.vue';
import { ref } from 'vue';
import numConvert from '@/js/numConvert';
import { useRouter } from 'vue-router';

const router = useRouter();
const searchList = ref([
  {
    label: '红人姓名',
    type: 'input',
    key: 'date'
  },
  {
    label: '国家筛选',
    type: 'select',
    key: 'country',
    options: [
      {
        label: '是',
        value: 1
      },
      {
        label: '否',
        value: 2
      }
    ]
  },
  {
    label: '红人分类',
    type: 'select',
    key: 'cate',
    options: [
      {
        label: '是',
        value: 1
      },
      {
        label: '否',
        value: 2
      }
    ]
  },
  {
    label: '是否接单',
    type: 'select',
    key: 'asterisk',
    options: [
      {
        label: '是',
        value: 1
      },
      {
        label: '否',
        value: 2
      }
    ]
  },
  {
    label: '合作状态',
    type: 'select',
    key: 'status',
    options: [
      {
        label: '未合作',
        value: 1
      },
      {
        label: '合作中',
        value: 2
      },
      {
        label: '已合作',
        value: 3
      },
      {
        label: '取消合作',
        value: 4
      }
    ]
  },
  {
    label: '合作阶段',
    type: 'select',
    key: 'status',
    options: [
      {
        label: '意向沟通',
        value: 1
      },
      {
        label: '合作中',
        value: 2
      },
      {
        label: '上线',
        value: 3
      },
      {
        label: '完成',
        value: 4
      }
    ]
  }
]);
const form = ref({
  total: 100
});
const tableData = ref([
  {
    id: 1,
    value: 'xxxx',
    avatar: 'https://www.wotohub.com/static/img/koc_default_man.8132f247.svg',
    count: 815324
  }
]);

const searchConfirm = e => {
  form.value = {
    ...e
  };
}
const toPath = url => {
  router.push(url);
}
</script>

<style lang="less" scoped>
.main {
  padding: 16px;
}

.wrap {
  background: #fff;
  padding: 16px;
  border-radius: 2px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .04), 0 2px 8px rgba(0, 0, 0, .04);

  .table {
    &::v-deep {
      .el-table__cell {
        height: 80px;
      }
    }

    .row-avatar {
      width: 50px;
      height: 50px;
      border-radius: 8px;
    }
  }

  .pagination {
    justify-content: end;
    height: 64px;
  }
}
</style>
